package com.person.leetcode.editor.cn;

/**
 * 48.旋转图像
 * 2022-11-01 17:11:07
 **/
public class Sequence_0048_RotateImage {
    public static void main(String[] args) {
        Solution solution = new Sequence_0048_RotateImage().new Solution();
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public void rotate(int[][] matrix) {
            //将矩阵一分为二转置
            //4  0,1 => 1,3  2,0 => 0,1
            //x,y => y,n-x    n = 3
            //2,2    2,1
            int n = matrix.length;
            int[][] matrix_new = new int[n][n];
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < n; ++j) {
                    matrix_new[j][n - i - 1] = matrix[i][j];
                }
            }
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < n; ++j) {
                    matrix[i][j] = matrix_new[i][j];
                }
            }
        }
    }

//leetcode submit region end(Prohibit modification and deletion)

}